package com.dms.common.service.impl;

import com.dms.common.service.LogService;
import com.dms.modules.system.service.OperationLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 日志服务实现类
 */
@Slf4j
@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private OperationLogService operationLogService;

    @Override
    public void logOperation(String module, String operation, String content) {
        operationLogService.logOperation(null, module, operation, content);
    }

    @Override
    public void logError(String module, String errorType, String content) {
        log.error("[{}] {}: {}", module, errorType, content);
    }

    @Override
    public void logSystem(String module, String level, String content) {
        switch (level.toUpperCase()) {
            case "ERROR":
                log.error("[{}] {}", module, content);
                break;
            case "WARN":
                log.warn("[{}] {}", module, content);
                break;
            case "INFO":
                log.info("[{}] {}", module, content);
                break;
            case "DEBUG":
                log.debug("[{}] {}", module, content);
                break;
            default:
                log.info("[{}] {}", module, content);
        }
    }
} 